﻿//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1998-2024 Glodon Company Limited.
//
// Licensed under the MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the “Software”),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////////


#ifndef SHAREDPARADEFINEDLG_H
#define SHAREDPARADEFINEDLG_H

#pragma once
#include "ComponentEditorGnufUI.h"
#include "FamilyParameterType.h"
#include "IFamilyParameterDefinition.h"
#include "UniIdentity.h"
#include "ui_sharedparadefinedlg.h"
#include <QtWidgets/QDialog>

class IExprEngine;

namespace gcmp
{
    class IParameterValueList;

}

namespace gfam
{
    class IFamilyManager;
    class FamDimConstraint;

    //自定义参数数据，用于xml读取配置
    struct SharedParaDefineData
    {
        std::wstring Name;//参数名称
        std::wstring GroupName; // 参数分组名称，将存入gac
        std::wstring Group; //分组
        gcmp::UniIdentity Uid; //参数Uid
        std::wstring Desc; //参数描述
        FamilyParameterType ParamType;//参数类型
        bool UserVisible; //用户是否可见
        bool UserModifiable; // 用户是否可编辑
        bool IsInstance; // 是否实例参数
        std::wstring Formula; // 公式

        gcmp::OwnerPtr<gcmp::IParameterValueList> ValueList;

        SharedParaDefineData(const SharedParaDefineData& source);
        SharedParaDefineData(SharedParaDefineData&& source);
        SharedParaDefineData();
    };

    class COMPONENT_EDITOR_GNUF_UI_EXPORT SharedParaDefineDlg : public QDialog
    {
        Q_OBJECT

    public:
        SharedParaDefineDlg(QWidget *parent = nullptr);
        ~SharedParaDefineDlg();

    public:

        gcmp::OwnerPtr<SharedParaDefineData> GetSelectParamData();

    public Q_SLOTS:
        void OnSelectGroup(const QString& text);
        void OnSelectParameter(int currentRow);
        void OnOpenFileDialog();

    private:
        void onMoveRequested(const QPoint& cursorPos, const QPoint& offset);
        
    private:
        Ui::SharedParaDefineDlg ui;
        
        std::map<std::wstring, std::vector<gcmp::OwnerPtr<SharedParaDefineData>>> m_customParameterDatas;

        SharedParaDefineData* m_pCurParamData;

        static std::wstring m_cachedPath;

    public:

    };
}

#endif // SHAREDPARADEFINEDLG_H
